import wepy from 'wepy'
import { icons } from './config'

const utils = {
  checkLogin: () => {
    try {
      let token = wepy.getStorageSync('access_token')
      return !!token
    } catch (e) {
      return false
      // Do something when catch error
    }
  },
  checkPhone: (phone) => {

    let reg = /^[1][3,4,5,7,8][0-9]{9}$/
    if (reg.test(phone)) {
      return true
    } else {
      wepy.showToast({
        title: '手机格式不正确',
        image: icons.error_icon,
        duration: 2000
      })
      return false
    }
  }
}

export default utils
